var vue = new Vue({
    el:"#app",
    data:{
        tv:{destId:''},
        dests:{},
        content:''
    },
    filters:{
        dateFormat:function(date){
            return dateFormat(date, "YYYY-MM-DD")
        }
    },
    methods:{
        chosePic:function () {
            $("#coverBtn").click();
        },
        saveOrUpdate:function (state) {
            $("#state").val(state);
            var param = $("#editForm").serialize() ;
            ajaxPost("/travels/saveOrUpdate", param, function (data) {
                //还缺一参数：目的地id
                var destId = $("#region").val();
                window.location.href = "/views/travel/detail.html?id=" + data.data + "&destId=" + destId;
            })
        }
    },
    mounted:function () {
        var id = getParams().id; //因为编辑和添加是同一个页面,为了区分开编辑和添加,所以要给编辑单独给定一个id值
        //游记编辑
        ajaxGet("/travels/input",{id:id}, function (data) {
            var map = data.data;
            if(map.tv){//  tv是travel的缩写,当UID有值的时候需要进行回显
                vue.tv = map.tv;
                ue.setContent( map.tv.content);
            }
            vue.dests = map.dests;
        })
    }
});

